﻿using System.ComponentModel;

namespace Tiscs.Practices.Presentation
{
    /// <summary>
    /// 视图模型基类。
    /// </summary>
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        /// <summary>
        /// 继承自<see cref="INotifyPropertyChanged"/>接口的事件。属性改变通知事件。
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 触发属性更改事件。
        /// </summary>
        /// <param name="propertyName">发生变化的属性名称。</param>
        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
